<script type="text/javascript">
    var prefix='$1';
        function GetCount()
        {
            var hdn = document.getElementById(prefix + 'hdnOptions').value;
            if(hdn)
            {
                var options = hdn.split('}}{{');
                if(options==null)
                    return 0;
                else
                    return options.length;
            }
            else
                return 0;
        }
        function ValidateOption()
        {
            var cnt = GetCount();
            if(cnt>=20)
            {
                alert("Maximum limit reached.");
                return false;
            }
            if(document.getElementById(prefix + 'txtOptions').value.replace(/^\s+|\s+$/g,'')=='')
            {
                alert("Empty Option not allowed.");
                return false;
            }
            return true;
        }
        function AddOption()
        {
            if(!ValidateOption())
                return false;
			document.getElementById(prefix + 'hdnOptions').value+='{{' + document.getElementById(prefix + 'txtOptions').value + '}}';
            return DisplayOption();
        }
        function DisplayOption()
        {
            var cnt = GetCount();
            if(cnt>=2)
            {
                var txt = document.getElementById(prefix + 'txtOptions');
                txt.setAttribute("class", "textbox"); 
                txt.setAttribute("className", "textbox"); 
            }
            var hdn = document.getElementById(prefix + 'hdnOptions').value;
            if(hdn || hdn!="")
            {
                document.getElementById('divOptions').innerHTML="";
                var options = hdn.split('}}{{');
                for (var x = 1; x <= options.length; x++)
                {
                    document.getElementById('divOptions').innerHTML+= x + ". " + options[x-1].replace('}}','').replace('{{','') + "<br/>";
                }
            }
            document.getElementById(prefix + 'txtOptions').value="";
            return true;
        }
        function ValidateForm()
        {
            var cnt = GetCount();
            if(document.getElementById(prefix + 'txtQuestion').value.replace(/^\s+|\s+$/g,'')=='')
            {
                alert("Question can not be Empty.");
                return false;
            }
            if(cnt < 2)
            {
                alert("You must give atleast two Options.");
                return false;
            }
            return true;
        }
    </script>